package com.edu.chongdian;

import android.os.Bundle;
import android.util.Log;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.edu.chongdian.model.Reward;

import java.util.ArrayList;
import java.util.List;

public class ShangchengMainActivity extends AppCompatActivity {
    private RecyclerView mRecyclerView;
    private RewardAdapter mAdapter;
    private TextView textView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.shangchengactivity_main);
        textView=findViewById(R.id.zongfen);
        List<Reward> rewards = new ArrayList<>();
        rewards.add(new Reward("奖励1", "这是奖励1的描述", 50, R.drawable.ic_launcher_background));
        rewards.add(new Reward("奖励2", "这是奖励2的描述", 80, R.drawable.ic_launcher_background));
        rewards.add(new Reward("奖励3", "这是奖励3的描述", 100, R.drawable.ic_launcher_background));
        mRecyclerView = findViewById(R.id.recycler_view);
        mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
        int intent = (int)getIntent().getIntExtra("data",0);
        mAdapter = new RewardAdapter(rewards);
        mRecyclerView.setAdapter(mAdapter);
        mAdapter.setPoints(intent);
        int i = mAdapter.getmPoints();
        Log.e("TAG","剩余"+i);
        textView.setText(String.valueOf(i));
        mAdapter.notifyDataSetChanged();
            Log.e("TAG", String.valueOf(intent));
    }
}